package com.wuh.service.impl;

import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.wuh.mapper.GroupMapper;
import com.wuh.model.*;
import com.wuh.service.GroupService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service

public class GroupServiceImpl implements GroupService {

    @Autowired
    private GroupMapper groupMapper;


    @Override
    public PageInfo<GroupInfo> getGroups(GroupInfo groupInfo) {
            PageHelper.startPage(groupInfo.getPageNum(),groupInfo.getPageSize());
        List<GroupInfo> list = groupMapper.getGroups(groupInfo);
        PageInfo<GroupInfo> pageInfo = new PageInfo<>(list);
        return pageInfo;
    }

    @Override
    public List<GroupInfo> getGroups1(GroupInfo groupInfo) {
        return groupMapper.getGroups1(groupInfo);
    }


    @Override
    public void insertGroup(GroupInfo groupInfo) {
            groupMapper.insertGroup(groupInfo);
    }

    @Override
    public GroupInfo selectGroupById(Integer id) {
        return groupMapper.selectGroupById(id);
    }

    @Override
    public void insertGroupUser(GroupUser groupUser) {
            groupMapper.insertGroupUser(groupUser);
    }

    @Override
    public List<GroupUser> getGroupUser(GroupUser groupUser) {
        return  groupMapper.getGroupUser(groupUser);
    }

    @Override
    public void deleteGroupUser(GroupUser groupuser) {
            groupMapper.deleteGroupUser(groupuser);
    }

    @Override
    public void deleteGroupInfo(Integer gid) {
            groupMapper.deleteGroupInfo(gid);
    }

    @Override
    public void insertApply(GroupAdminApply groupAdminApply) {
        groupMapper.insertApply(groupAdminApply);
    }

    @Override
    public void deleteApply(Integer gid) {
        groupMapper.deleteApply(gid);
    }

    @Override
    public int getCountByGroupId(Integer gid) {
        return groupMapper.getCountByGroupId(gid);
    }

    @Override
    public void updateGroupInfo(GroupInfo groupInfo) {
        groupMapper.updateGroupInfo(groupInfo);
    }

    @Override
    public List<GroupAdminApply> getGroupAdminApply(GroupAdminApply groupAdminApply) {
        return groupMapper.getGroupAdminApply(groupAdminApply);
    }

    @Override
    public void updateGroupAdminApply(GroupAdminApply groupAdminApply) {
                    groupMapper.updateGroupAdminApply(groupAdminApply);
    }

    @Override
    public void updateGroupUser(GroupUser groupUser) {
            groupMapper.updateGroupUser(groupUser);
    }

    @Override
    public int getAdminCountByGroupId(GroupUser groupUser) {
        return groupMapper.getAdminCountByGroupId(groupUser);
    }
}
